<style>
    .welcome .layui-card {border:1px solid #f2f2f2;border-radius:5px;}
    .welcome .icon {margin-right:10px;color:#1aa094;}
    .welcome .icon-cray {color:#ffb800 !important;}
    .welcome .icon-blue {color:#1e9fff !important;}
    .welcome .icon-tip {color:#ff5722 !important;}
    .welcome .layuimini-qiuck-module {text-align:center;margin-top:10px}
    .welcome .layuimini-qiuck-module a i {display:inline-block;width:100%;height:60px;line-height:60px;text-align:center;border-radius:2px;font-size:30px;background-color:#F8F8F8;color:#333;transition:all .3s;-webkit-transition:all .3s;}
    .welcome .layuimini-qiuck-module a cite {position:relative;top:2px;display:block;color:#666;text-overflow:ellipsis;overflow:hidden;white-space:nowrap;font-size:14px;}
    .welcome .welcome-module {width:100%;}
    .welcome .panel {background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
    .welcome .panel-body {padding:10px}
    .welcome .panel-title {margin-top:0;margin-bottom:0;font-size:12px;color:inherit}
    .welcome .label {display:inline;padding:.5em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top:.3em;}
    .welcome .layui-red {color:red}
    .welcome .main_btn > p {height:40px;}
    .welcome .layui-bg-number {background-color:#F8F8F8;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <div class="layuimini-main welcome">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-row layui-col-space15">
                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-warning icon"></i>基础数据</div>
                            <div class="layui-card-body">
                                <div class="welcome-module">
                                    <div class="layui-row layui-col-space10">
                                        <div class="layui-col-xs6">
                                            <div class="panel layui-bg-number">
                                                <div class="panel-body">
                                                    <div class="panel-title">
                                                        <span class="label pull-right layui-bg-blue">实时</span>
                                                        <h5>雪花ID节点数量</h5>
                                                    </div>
                                                    <div class="panel-content">
                                                        <h1 class="no-margins" id="workNodeQuantity">1234</h1>
                                                        <small>当前分类总记录数</small>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-col-xs6">
                                            <div class="panel layui-bg-number">
                                                <div class="panel-body">
                                                    <div class="panel-title">
                                                        <span class="label pull-right layui-bg-cyan">实时</span>
                                                        <h5>流水号数量</h5>
                                                    </div>
                                                    <div class="panel-content">
                                                        <h1 class="no-margins" id="idTableQuantity">1234</h1>
                                                        <small>当前分类总记录数</small>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md12">
                        <div class="layui-card">
                            <div class="layui-card-header"><i class="fa fa-line-chart icon"></i>流水号访问量Top25</div>
                            <div class="layui-card-body">
                                <table class="layui-hide" id="dashboardTableId" lay-filter="dashboardTableFilter"></table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    layui.use(['layer', 'table', 'miniAjax'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            table = layui.table,
            miniAjax = layui.miniAjax;

        miniAjax.get({
            url: '/dashboard/quantity',
            success: function (res) {
                if (res.code == '0') {
                    // 刷新数据
                    $("#idTableQuantity").text(res.data.idTableQuantity);
                    $("#workNodeQuantity").text(res.data.workNodeQuantity);
                } else {
                    layer.msg(res.msg, {time: 1000, icon: 2});
                }
            },
            error: function (error) {
                layer.msg(error, {time: 1000, icon: 2});
            }
        });

        var dashboardTable = table.render({
            elem: '#dashboardTableId',
            url: '/dashboard/topList',
            method: 'get',
            parseData: function (res) {
                return {
                    "code": res.code,
                    "msg": res.msg,
                    "data": res.data
                };
            },
            defaultToolbar: ['filter', 'exports', 'print'],
            cols: [[
                {type: 'numbers', width: '5%', title: '#', align: 'center'},
                {field: 'idCode', width: '15%', title: '编码', align: 'center'},
                {field: 'idName', width: '15%', title: '名称'},
                {field: 'idValue', width: '10%', title: '当前值'},
                {field: 'idLength', width: '10%', title: '长度'},
                {field: 'idStep', width: '10%', title: '步长'},
                {field: 'idPrefix', width: '10%', title: '前缀'},
                {field: 'idSuffix', width: '10%', title: '后缀'},
                {field: 'createdAt', width: '15%', title: '创建时间'}
            ]],
            skin: 'line'
        });
    });
</script>
